import { useEffect, useState } from "react"

export default function usePostion(){
    let [x, setX] = useState(100)
    let [y, setY] = useState(100)
   
    function move(e){
        setX(e.clientX)
        setY(e.clientY)
    }
    useEffect(()=>{
        window.addEventListener('mousemove',move)
        return ()=>{
            // 卸载移除自定义事件
            window.removeEventListener('mousemove',move)
        }

    },[])
    return {
        x,y
    }
}